package com.huabo.contract.service.impl;

import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.hbfk.entity.DealUserToken;
import com.hbfk.entity.TblStaffUtil;
import com.hbfk.util.JsonBean;
import com.hbfk.util.PageInfo;
import com.hbfk.util.ResponseFormat;
import com.huabo.contract.oracle.entity.TblStaff;
import com.huabo.contract.oracle.mapper.TblStaffMapper;
import com.huabo.contract.service.UserService;

@Service
public class UserServiceImpl implements UserService {
	@Autowired
    private TblStaffMapper tblStaffMapper;
	
//	@Autowired
//    private ActivityPluginsService activityPluginsService;

	@Override
	public JsonBean findAllPageBeanPid(String token, Integer pageNumber, Integer pageSize,Integer orgid) throws Exception {
		TblStaffUtil loginStaff = DealUserToken.parseUserToken(token);
		if(loginStaff == null) {
			return ResponseFormat.retParam(0,20006,null);
		}
		
		if(null == orgid) {
			orgid = loginStaff.getCurrentOrg().getOrgid().intValue();
		}
		
    	if(pageNumber == null) {
    		pageNumber = 1;
    	}
    	if(pageSize==null) {
    		pageSize=15;
    	}
    	Map<String,Object> resultMap = new HashMap<String,Object>(0);
    	
    	PageInfo<TblStaff> pageInfo = new PageInfo<TblStaff>();
//    	tblNbsjSheet.setAuditorgid(loginStaff.getCurrentOrg().getOrgid());
//    	pageInfo.setCondition(tblNbsjSheet);
    	pageInfo.setPageSize(pageSize);
    	pageInfo.setCurrentPage(pageNumber);
    	pageInfo.setTlist(this.tblStaffMapper.selectTreeListByPageInfo(pageInfo,orgid));
    	pageInfo.setTotalRecord(this.tblStaffMapper.selectTreeCountByPageInfo(pageInfo,orgid));
    	pageInfo.getTotalPage();
//    	String identifier = activityPluginsService.getoNState(ProcessEnum.SJ_JHGL.name());
//    	resultMap.put("identifier", identifier);
    	resultMap.put("pageInfo", pageInfo);
    	return ResponseFormat.retParam(1,200,resultMap);
	}

}
